home *** CD-ROM | disk | FTP | other *** search
- /* AOMDecorateDisplay.c */
- /*
- * AddressOMatic Sample
- * AOMCreatePanels.c
- * Copyright © 1993 Apple Computer Inc. All rights reserved.
- * The functions in this module organize the visual appearance of the
- * AOM panel. You should note the following:
- *
- * Radio buttons
- * The four radio buttons are always aligned to the top-left of the
- * display. (In Right-to-Left systems, they should be positioned at
- * the top-right; but not right now.)
- * Action buttons
- * The "to" button is at the bottom right, with the "cc" button next
- * to it. The "done" button is at the bottom left.
- * SDP Panel
- * The SDP Panels are "elastic" -- the top-left is fixed in position
- * while the bottom-right is fixed with respect to the bottom-right
- * of the window.
- * Spinner
- * The spinner is fixed with respect to the top-right corner.
- * Panel Label
- * The panel label is centered over the SDP Panel area.
- */
- #include "AddressOMaticPrivate.h"
-
- void _AOMDecorateButton(
- register AddressOMaticPtr aomPtr,
- ControlHandle theControl,
- AOMItemIndex index
- );
-
- /*
- * _AOMDecorateDisplay is a private function that is called when the window
- * is created, moved, or when it changes size. It computes all item rectangles.
- */
- void
- _AOMDecorateDisplay(
- register AddressOMaticPtr aomPtr
- )
- {
- short i;
- #ifdef ENABLE_TYPEIN
- Str255 work;
- #endif
-
- EraseRect(&BOUNDS);
- ValidRect(&BOUNDS);
- /*
- * Inset the user specification to make room for the big fat
- * drop shadow.
- */
- INTERIOR = BOUNDS;
- INTERIOR.right -= kAOMDropShadowWidth;
- INTERIOR.bottom -= kAOMDropShadowWidth;
- /*
- * Position the radio buttons
- */
- SetRect(
- &RECT(kAOMPDButtonItem),
- INTERIOR.left + kAOMRadioButtonLeft,
- INTERIOR.top + kAOMRadioButtonTop,
- INTERIOR.left + kAOMRadioButtonLeft + kAOMRadioButtonSize,
- INTERIOR.top + kAOMRadioButtonTop + kAOMRadioButtonSize
- );
- InvalRect(&RECT(kAOMPDButtonItem));
- for (i = kAOMDirButtonItem; i <= kAOMLastRadio; i++) {
- RECT(i) = RECT(i - 1);
- OffsetRect(&RECT(i), 0, kAOMRadioButtonVOffset);
- InvalRect(&RECT(i));
- }
- /*
- * Position the SDP Panel area
- */
- SetRect(
- &PANEL,
- INTERIOR.left + kAOMPanelLeftInset,
- INTERIOR.top + kAOMPanelTopInset,
- INTERIOR.right - kAOMPanelRightInset,
- INTERIOR.bottom - kAOMPanelBottomInset
- );
- /*
- * Position the components of the Type-In Panel.
- */
- #ifdef ENABLE_TYPEIN
- SetRect(
- &RECT(kAOMTypeInAddrLabelItem),
- PANEL.left,
- INTERIOR.top + kAOMTypeInAddressLabelTop,
- PANEL.right,
- INTERIOR.top + kAOMTypeInAddressLabelTop + kAOMLabelFontHeight
- );
- GetIndString(work, AOM.stringsResID, kAOMTypeInDirLabelString);
- _AOMSetFont(aomPtr, kAOMLabelFontStyle);
- SetRect(
- &RECT(kAOMTypeInAddressItem),
- PANEL.left,
- INTERIOR.top + kAOMTypeInAddressTop,
- PANEL.right,
- INTERIOR.top + kAOMTypeInAddressBottom
- );
- /*
- * See the note in AOMTypeInManager: we keep a separate popup title
- * so the panel looks correct.
- */
- SetRect(
- &RECT(kAOMTypeInDirLabelItem),
- PANEL.left,
- INTERIOR.top + kAOMTypeInDirectoryLabelTop,
- PANEL.left + StringWidth(work),
- INTERIOR.top + kAOMTypeInDirectoryLabelTop + kAOMLabelFontHeight
- );
- SetRect(
- &RECT(kAOMTypeInDirectoryItem),
- RECT(kAOMTypeInDirLabelItem).right + CharWidth('n'),
- INTERIOR.top + kAOMTypeInPopupTop,
- PANEL.right,
- INTERIOR.top + kAOMTypeInPopupTop + kAOMTypeInPopupHeight
- );
- #endif
- /*
- * Extend the SDP Panel area so there is space for the
- * Focus rectangle (which extends beyond the panel area)
- */
- EXTERIOR = PANEL;
- InsetRect(&EXTERIOR, -4, -4);
- /*
- * Position the action buttons -- after the SDP Panel
- */
- SetRect(
- &RECT(kAOMDoneButtonItem),
- RECT(kAOMSDPPanelItem).left,
- INTERIOR.bottom - (kAOMButtonBottomInset + kAOMButtonHeight),
- RECT(kAOMSDPPanelItem).left + kAOMDoneButtonWidth,
- INTERIOR.bottom - kAOMButtonBottomInset
- );
- SetRect(
- &RECT(kAOMToButtonItem),
- RECT(kAOMSDPPanelItem).right - kAOMToButtonWidth,
- RECT(kAOMDoneButtonItem).top,
- RECT(kAOMSDPPanelItem).right,
- RECT(kAOMDoneButtonItem).bottom
- );
- RECT(kAOMCCButtonItem) = RECT(kAOMToButtonItem);
- OffsetRect(
- &RECT(kAOMCCButtonItem),
- - (kAOMCCButtonWidth + kAOMCCButtonGap),
- 0
- );
- RECT(kAOMCCButtonItem).right =
- RECT(kAOMCCButtonItem).left + kAOMCCButtonWidth;
- /*
- * Position the spinner
- */
- SetRect(
- &RECT(kAOMSpinnerItem),
- INTERIOR.right - kAOMSpinnerRightInset,
- INTERIOR.top + kAOMSpinnerTopInset,
- INTERIOR.right - kAOMSpinnerRightInset + kAOMSpinnerSize,
- INTERIOR.top + kAOMSpinnerTopInset + kAOMSpinnerSize
- );
- /*
- * Position the panel label
- */
- SetRect(
- &TITLE,
- RECT(kAOMSDPPanelItem).left,
- INTERIOR.top + kAOMPanelLabelTop,
- RECT(kAOMSpinnerItem).left - 1,
- INTERIOR.top + kAOMPanelLabelTop + kAOMPanelLabelHeight
- );
- /*
- * Now, reposition the window content.
- */
- _AOMDecorateButton(aomPtr, AOM.doneButton, kAOMDoneButtonItem);
- _AOMDecorateButton(aomPtr, AOM.ccButton, kAOMCCButtonItem);
- _AOMDecorateButton(aomPtr, AOM.toButton, kAOMToButtonItem);
- /*
- * Reposition the SDP stuff
- */
- if (AOM.pdPanel != NULL)
- _AOMPanelAdjust(aomPtr, AOM.pdPanel);
- if (AOM.browsePanel != NULL)
- _AOMPanelAdjust(aomPtr, AOM.browsePanel);
- if (AOM.findPanel != NULL)
- _AOMFindAdjust(aomPtr);
- #ifdef ENABLE_TYPEIN
- _AOMTypeInAdjust(aomPtr);
- #endif
- }
-
- /*
- * Position one of the buttons.
- */
- void
- _AOMDecorateButton(
- register AddressOMaticPtr aomPtr,
- ControlHandle theControl,
- AOMItemIndex index
- )
- {
- Rect viewRect;
-
- viewRect = RECT(index);
- if (theControl != NULL
- && EqualRect(&(**theControl).contrlRect, &viewRect) == FALSE) {
- HideControl(theControl);
- MoveControl(theControl, viewRect.left, viewRect.top);
- SizeControl(theControl, width(viewRect), height(viewRect));
- if (AOM.isVisible)
- ShowControl(theControl);
- }
- }
-